// 引入拦截器
import { request } from "@/utils/http";
import { Key } from "react";
// 引入类型限定
import type {
    getHosSetListParamsType,
    // 数据返回promise的类型限定
    getHosSetListReturnType,
    // 新增医院类型限定
    addHospitalParamType,
    // 获取医院设置信息类型
    getHosSetListItemsType,
    // 修改后再次提交的数据类型
    updateHospitalParamType

} from "./model/hospitalSetTypes";

// 医院设置中获取分页列表
export const getHosSetListRequest = ({ page, limit, hosname, hoscode }: getHosSetListParamsType) => {
    // 发送axios请求， 响应体的类型  返回的promise数据的类型
    return request.get<any, getHosSetListReturnType>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
        params: {
            hosname,
            hoscode
        }
    })
}


// 医院设置中 新增医院请求
export const addHospitalRequest = (data: addHospitalParamType) => {
    //          返回体数据为null
    return request.post<any, null>("/admin/hosp/hospitalSet/save", data)
}

// 医院设置中根据id获取某个详细的医院设置
export const getHosSetFromIdRequest = (id: string) => {
    return request.get<any, getHosSetListItemsType>(`/admin/hosp/hospitalSet/get/${id}`)

}

// 医院设置中根据id修改数据后再次提交修改
export const updateHosSetFromIdRequest = (data: updateHospitalParamType) => {
    return request.put<any, null>("/admin/hosp/hospitalSet/update", data)
}

// 医院设置中根据id删除某条数据
export const deleteHosSetFromIdRequest = (id: number) => {
    return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

// 医院设置批量删除设置
export const batchDeleteHosRequest = (ids: Key[]) => {
    return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
        data: ids
    })
}
